/**
 * 
 */
package com.dsteiner.xelavos.client;



import com.dsteiner.widgets.client.PaginationWidget;
import com.dsteiner.widgets.client.Widgets.FlowPanelExt;
import com.dsteiner.widgets.client.Widgets.HTMLExt;
import com.dsteiner.widgets.client.Widgets.IWidget;
import com.dsteiner.widgets.client.Widgets.IWidgetBuilder;
import com.dsteiner.widgets.client.Widgets.LazyWidget;
import com.dsteiner.widgets.client.model.PaginationModel;
import com.dsteiner.xelavos.client.controller.MyEntriesController;
import com.dsteiner.xelavos.client.model.AuthenticationModel;
import com.dsteiner.xelavos.client.model.DisplayModel;
import com.dsteiner.xelavos.client.model.MyEntriesModel;
import com.dsteiner.xelavos.client.resources.XelavosResources;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Widget;

public class MyEntriesWidget extends LazyWidget implements IWidgetBuilder{
	
	private MyEntriesController myEntriesController = new MyEntriesController();
	private MyEntriesModel myEntriesModel;
	private final AuthenticationModel authenticationModel;
	public MyEntriesWidget(MyEntriesModel myEntriesModel, AuthenticationModel authenticationModel) {
		this.myEntriesModel = myEntriesModel;
		this.authenticationModel = authenticationModel;
	}
	
	@Override
	public Widget createContentWidget() {
		FlowPanel mainPanel = new FlowPanel();
		FlowPanelExt contentPanel = new FlowPanelExt();
		PaginationModel paginationModel = new PaginationModel();
		PaginationWidget paginationWidget = new PaginationWidget(paginationModel);
		
		mainPanel.add(contentPanel);
		mainPanel.add(paginationWidget);
		
		setStyleName(XelavosResources.INSTANCE.css().myEntriesWidget());
		
		myEntriesController.registerMyEntriesModel(myEntriesModel);
		myEntriesController.registerMyEntriesWidget(this);
		myEntriesController.registerWidgetBuilder(this);
		myEntriesController.registerContentPanel(contentPanel);
		myEntriesController.registerPaginationModel(paginationModel);
		return mainPanel;
	}

	public IWidget createWidget(Object model) {
		DisplayModel editModel = (DisplayModel) model;
		DisplayWidget editWidget = new DisplayWidget(editModel, authenticationModel);
		return editWidget;
	}
}